package il.ac.tau.cvws.scrabblesidekick.client.ui;

import il.ac.tau.cvws.scrabblesidekick.client.app.controller.ScrabbleSidekickController;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;

/* Base activity class. Most of the functionality is implemented in its
 * subclasses, and the main functionality here relates to the screen and
 * to creating the controllers.
 */
public abstract class ScrabbleSidekickActivity extends Activity
{
	protected ScrabbleSidekickController _controller;
	
	protected int _screenHeight;
	protected int _screenWidth;
	
	@SuppressLint("NewApi")
	@SuppressWarnings("deprecation")
	@Override
    public void onCreate(Bundle savedInstanceState) 
	{
		super.onCreate(savedInstanceState);
	
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
 		{
 			android.graphics.Point size = new android.graphics.Point();
 			getWindowManager().getDefaultDisplay().getSize(size);
 			
 			_screenHeight = size.x;
 			_screenWidth  = size.y;
 		}
		else
		{
			_screenHeight = getWindowManager().getDefaultDisplay().getHeight();
			_screenWidth  = getWindowManager().getDefaultDisplay().getWidth(); 
		}
		
		_controller = createController();
	}

	public void invokeStartActivityForResult(Intent intent, int requestCode)
	{
		startActivityForResult(intent, requestCode);
	}
 	
	protected abstract ScrabbleSidekickController createController();
}
